package com.intercepter;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
public class LoginIntercepter extends MethodFilterInterceptor{

	@Override
	protected String doIntercept(ActionInvocation arg0) throws Exception {
		
		//获得session
				Map<String, Object> session = ActionContext.getContext().getSession();
				//获得登录标识
				Object object = session.get("username");
				//判断登录标识是否存在
				if(object == null){
					//不存在=>没登录=>重定向到login.jsp
					return "toLogin";
				}else{
					//存在=>已经登录=>放行
					return arg0.invoke();
				}
	}
	
	
	
	

}
